/*
 * EquilibriumConditions.h
 *
 *  Created on: 11 Nov 2011
 *      Author: allan
 */

#ifndef EQUILIBRIUMCONDITIONS_H_
#define EQUILIBRIUMCONDITIONS_H_

// C++ includes
#include <vector>
using namespace std;

// Eigen includes
#include <Eigen/Core>
using namespace Eigen;

// GeoReact includes
#include <Utils/Types.h>

struct EquilibriumCondition
{
	/// The alpha row that represents mathematically the equilibrium condition
	VectorXd alpha_row;
	
	/// The function h = h(T, P, n, a) that represents mathematically the right-hand side of the equilibrium condition
	FunctionTPna hj;
	
	EquilibriumCondition()
	: hj(ConstantTPna(0.0))	{}
	
	EquilibriumCondition(unsigned N)
	: hj(ConstantTPna(0.0)) { alpha_row = VectorXd::Zero(N); }
};

class EquilibriumConditions
{
public:
	EquilibriumConditions();
	
	EquilibriumConditions(const vector<EquilibriumCondition>& conditions);
	
	void SetConditionMatrix(const MatrixXd& alpha);
	
	void SetConditionFunctions(const vector<FunctionTPna>& hj);
	
	void SetConditionFunctions(const VectorXd& hj);
	
	void SetConditions(const vector<EquilibriumCondition>& conditions);
	
	const MatrixXd& GetConditionMatrix() const;
	
	const VectorXd EvaluateConditionFunctions(double T, double P, const VectorXd& n, const VectorXd& a) const;
	
private:
	MatrixXd alpha;
	
	vector<FunctionTPna> hj_function;
	
	VectorXd hj_constant;
};

#endif /* EQUILIBRIUMCONDITIONS_H_ */
